<template>
	<view class="container2">
		<form @submit="formSubmit">
			<view class="square1">
				<view class="subname">{{SubName}}</view>
			</view>
			<view class="square1" v-if="(OldList.length+ImgList.length)>0">
				<view class="line1">
					<view class="img border" v-for="(img,index) in OldList"><image :src="Tools.GetImg(img,500)" mode="aspectFill" @click="PrevImg(OldList,index)"/><view class="delete" @click="DeleteImg1(index)" @click.stop="" v-if="Entity.State==1"><image src="/static/error.png"/></view></view>
					<view class="img border" v-for="(img,index) in ImgList"><image :src="img" mode="aspectFill" @click="PrevImg(ImgList,index)"/><view class="delete" @click="DeleteImg2(index)" @click.stop="" v-if="Entity.State==1"><image src="/static/error.png"/></view></view>
				</view>
			</view>
			<template v-else>
				<view class="nodata"></view>
				<view class="loadmore">暂无图片</view>
			</template>				
			
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				ID:0,
				Info:{},
				Domain:'',
				Entity:{},
				CaseID:0,
				RoleID:0,
				SubName:'',
				Method:'',
				OldList:[],
				ImgList:[]
			};
		},
		onLoad(options) {
			uni.setNavigationBarTitle({title:options.SubName});
			this.SubName=options.SubName;
			this.CaseID=options.CaseID;
			this.Method=options.Method;
			this.RoleID=uni.getStorageSync("RoleID");
			this.Domain = uni.getStorageSync("Domain");
			this.Find_CaseInfo();
		},
		methods:{
			SendDateChange(e){
				this.Info.SendDate = e.f1;
			},
			Find_CaseInfo(){
				var data = {};
				data.Act="Find_AnnexInfo_County";
				data.CaseID=this.CaseID;
				data.Method=this.Method;
				data.Domain = this.Domain;
				this.Util.Loading("加载中...");
				this.Util.Post(data, json=>{
					this.Util.HideLoading();
					uni.stopPullDownRefresh();
					uni.hideNavigationBarLoading();
					this.ID=json.Data.Info.ID;
					this.Info=json.Data.Info;
					this.Entity=json.Data.Entity;
					this.ImgList=[];
					if(json.Data.Info.Path!=''){
						this.OldList = json.Data.Info.Path.split(',');
					}
				});
			},
			PrevImg(urls,index){
				uni.previewImage({
					current:index,
					urls: urls,
					longPressActions: {
						itemList: ['保存图片'],
						success: data=> {
							uni.saveImageToPhotosAlbum({
								filePath: urls[data.index],
								success: d=> {
									this.Util.Toast("已保存至系统相册");
								}
							});
						}
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.container2{padding-bottom: 180rpx;}	
</style>
